package za.org.jcicada.comms.impl.stub;

import static org.junit.Assert.assertFalse;
import static org.junit.Assert.assertTrue;

import java.util.LinkedList;

import za.org.jcicada.comms.IAcceptListener;
import za.org.jcicada.comms.IConnection;
import za.org.jcicada.comms.IKatcpSerializerStrategy;
import za.org.jcicada.comms.IMessageListener;

public class StubAcceptListener implements IAcceptListener {
	
    public LinkedList<IConnection> connections = new LinkedList<IConnection>();
    public IMessageListener messageListener = new StubMessageListener();

	@Override
	public void onAccept(IConnection client) throws Exception {
		assertFalse(connections.contains(client));
		connections.add(client);
		client.initialize(messageListener);
	}

	@Override
	public void onClose(IConnection client) throws Exception {
		assertTrue(connections.contains(client));
		connections.remove(client);
	}

	@Override
	public IKatcpSerializerStrategy getKatcpSerializerStrategy() {
		return null;
	}

}
